<template>
  <ul class="cat-menu">
    <!-- 一级分类 -->
    <li v-for="(item, index) in data" :key="index">
      <div class="cat-menu-title">
        <!-- 一级分类名称 -->
        <nuxt-link to>{{item.cat_name}}</nuxt-link>
      </div>
      <div class="cat-menu-content">
        <div class="row gutter">
          <div class="col-9">
            <ul class="cat-menu-tsubmenu">
              <!-- 一级分类下的按钮 -->
              <li v-for="(item1, index1) in item.btns" :key="index1">
                <nuxt-link to>{{item1.title}}</nuxt-link>
              </li>
            </ul>
            <!-- 二级分类 -->
            <div class="row cat-menu-tsubmenu" v-for="(item1, index1) in item.children" :key="index1">
              <div class="col-2">
                <!-- 二级分类名称 -->
                <nuxt-link to>{{item1.cat_name}}</nuxt-link>
              </div>
              <div class="col-10">
                <!-- 三级分类名称 -->
                <nuxt-link to v-for="(item2, index2) in item1.children" :key="index2">{{item2.cat_name}}</nuxt-link>
              </div>
            </div>
          </div>
          <div class="col-3 cat-menu-adimage">
            <!-- 品牌图片 -->
            <img
              v-for="(item1, index1) in item.brands"
              :key="index1"
              :src="item1.image"
            />
          </div>
        </div>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  props: {
    data: {
      type: Array,
      required: true
    }
  }
}
</script>

<style lang="scss">
.cat-menu {
  position: relative;
  padding: 6px 0;
  font-size: 14px;
  background: #fff;
  li {
    padding: 3px 15px;
    &:hover {
      background: #ddd;
      .cat-menu-content {
        display: block;
      }
    }
  }
  &-content {
    position: absolute;
    top: 0;
    left: 190px;
    display: none;
    padding: 20px;
    width: 990px;
    min-height: 500px;
    font-size: 12px;
    border: 1px solid #ccc;
    background: #fff;
    box-shadow: 0px 0px 4px #ccc;
    z-index: 9999;
  }
  &-tsubmenu {
    li {
      display: inline-block;
      margin-right: 10px;
      background: #333;
      &:hover {
        background: red;
      }
      a {
        color: #fff;
        &::after {
          content: ">";
          padding-left: 8px;
        }
      }
    }
  }
  &-bsubmenu {
    margin-top: 10px;
    a {
      margin-right: 10px;
      .col-2 {
        font-weight: bold;
        a {
          &::after {
            content: ">";
            padding-left: 8px;
          }
        }
      }
    }
  }
  &-adimage {
    img {
      width: 50%;
      border-right: 1px solid #fff;
      border-bottom: 1px solid #fff;
      box-sizing: border-box;
    }
  }
}
</style>